package com.spm.librarianmanagersystem.mapper;

import com.spm.librarianmanagersystem.pojo.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: 苏成
 * @Date: 2022/04/07/11:01
 * @Description:
 */

@Mapper
@Repository
public interface BookMapper {

    List<Book> getAllBook();

    Book getABook(String isbn);

    void updateBookLocation(String ISBN, Integer bookId);

    void updateBook(Book book);

    void insertBook(Map map);

    void deleteBook(String isbn);

    void addBookBook(Map map);

    int countBook(String ISBN);

    void deleteBorrow(String ISBN);

    void deleteRes(String ISBN);

    void deleteBookId(String ISBN);

    void deleteFine(int borrow_id);

    List<Integer> selectBorrowId(String ISBN);

    Integer getfine(int borrow_id);

    Integer getBookNum();

    @Select("SELECT * FROM book_book_id WHERE ISBN=#{isbn} AND book_id=#{bookId}")
    Book getBookById(String isbn, Integer bookId);

    @Delete("UPDATE book_book_id SET status=-3 WHERE ISBN=#{isbn} AND book_id=#{bookId}")
    Boolean deleteBookById(String isbn, Integer bookId);

    Boolean updateScore(String ISBN, Double score);

    List<Book> getBorrowedBook();

    List<Book> getMostPopularBook();
}
